/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tetris_invader.itens;

import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import tetris_invader.util.Fase;

/**
 *@brief Classe PieceFactory: Instancia as pecas
 */
public class PieceFactory {

    public enum PieceType {

        BOMB, BEAM, PLUS_LIFE, ENERGY, INVADER_BEAM, SPECIAL_BEAM;
    }

    private PieceFactory() {
    }

    public static Item fabricaPeca(Fase f, PieceType type) {

        if (type == PieceType.BEAM) {
            Image[] imagens = new Image[1];
            for (int i = 0; i < imagens.length; i++) {
                String filename = "/images/beam/navebeam.png";
                URL url = PieceFactory.class.getResource(filename);
                imagens[i] = Toolkit.getDefaultToolkit().getImage(url);
            }
            return new Beam(f, imagens);

        } else if (type == PieceType.PLUS_LIFE) {
            Image[] imagens = new Image[1];
            String filename = "/images/itens/life_item.png";
            URL url = PieceFactory.class.getResource(filename);
            imagens[0] = Toolkit.getDefaultToolkit().getImage(url);
            imagens[0] = imagens[0].getScaledInstance(15, 15, 1);

            return new Life_Item(f, imagens);
        } else if (type == PieceType.INVADER_BEAM) {
            Image[] imagens = new Image[1];
            String filename = "/images/beam/invaderbeam.png";
            URL url = PieceFactory.class.getResource(filename);
            imagens[0] = Toolkit.getDefaultToolkit().getImage(url);

            return new InvaderBeam(f, imagens);
        } else if (type == PieceType.ENERGY) {
            Image[] imagens = new Image[1];
            String filename = "/images/itens/energy.png";
            URL url = PieceFactory.class.getResource(filename);
            imagens[0] = Toolkit.getDefaultToolkit().getImage(url);
            imagens[0] = imagens[0].getScaledInstance(15, 15, 1);

            return new Energy_Item(f, imagens);
        } else if (type == PieceType.SPECIAL_BEAM) {
            Image[] imagens = new Image[3];
            for (int i = 0; i < imagens.length; i++) {
                String filename = "/images/beam/beam"+i+".png";
                URL url = PieceFactory.class.getResource(filename);
                imagens[i] = Toolkit.getDefaultToolkit().getImage(url);
            }
            return new SpecialBeam(f, imagens);
        }

        return null;
    }
}
